package com.agileboot.domain.airport.report.model;

import cn.hutool.core.bean.BeanUtil;
import com.agileboot.domain.airport.report.command.AddReportCommand;
import com.agileboot.domain.airport.report.command.UpdateReportCommand;
import com.agileboot.domain.airport.report.db.SirReportEntity;
import com.agileboot.domain.airport.report.db.SirReportService;
import lombok.NoArgsConstructor;

/**
 * 安全信息聚合根
 */
@NoArgsConstructor
public class ReportModel extends SirReportEntity {

    private SirReportService reportService;

    public ReportModel(SirReportService reportService) {
        this.reportService = reportService;
    }

    public ReportModel(SirReportEntity entity, SirReportService reportService) {
        if (entity != null) {
            BeanUtil.copyProperties(entity, this);
        }
        this.reportService = reportService;
    }

    public void loadFromAddCommand(AddReportCommand command) {
        if (command != null) {
            BeanUtil.copyProperties(command, this, "reportId");
        }
    }

    public void loadFromUpdateCommand(UpdateReportCommand command) {
        if (command != null) {
            loadFromAddCommand(command);
            this.setUpdaterBy(command.getUpdaterBy()); // 设置 updaterBy
        }
    }

    // 可根据业务扩展检查方法，如：checkDuplicateTitle、checkValidStatus 等
}
